package org.test.connectDB;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.apache.log4j.Logger;
import org.junit.Test;

public class ConnectMYSQL {

	@Test
	public void testMYSQL() throws ClassNotFoundException, SQLException {
		

		Class.forName("com.mysql.jdbc.Driver");
		Connection con = DriverManager.getConnection(
				"jdbc:mysql://localhost:3306/test", "root", "root");

		String s = "select * from user limit ?,?";
		PreparedStatement statement = con.prepareStatement(s);
		statement.setInt(1, 4);
		statement.setInt(2, 2);
		ResultSet rs = statement.executeQuery();

		while (rs.next()) {
			System.out.println(rs.getInt(1) + "..");
			System.out.println(rs.getString(2) + "..");
			System.out.println(rs.getString(3) + "..");
			System.out.println();
		}
	}
}
